/*
 * Conexion.java
 *
 */

package Servicio;

import java.sql.*;
import org.sqlite.JDBC;

/**
 * Conecta a la base de datos
 * 
 */
public class Conexion {
    private Connection connection;
    private static Conexion instancia = null;
        

    /** Crea una nueva instancia de Conexion y se conecta */
    private Conexion() {
    
    }

    /** Devuelve una unica instancia */
    public static Conexion getInstance(){
    if (instancia == null)
        instancia = new Conexion();
    else 
    {
                
    }
    return instancia;
    }

    public Connection getConexion(){
        return connection;
    }

    public void setConection(){
        try {
            String fileName = "base.s3db";
            Class.forName("org.sqlite.JDBC");
            connection = DriverManager.getConnection("jdbc:sqlite:"+fileName);
        } catch (Exception e) {
                e.printStackTrace();
        }
    }
    
    public void closeConection(){
        try {
        connection.close();
        } catch (Exception e) {e.printStackTrace(); }
    }


    
}